package servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/goodbye")
public class ServletD extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

//        ServletContext servletContext = getServletContext();
//        servletContext.removeAttribute("key2");

        HttpSession session = req.getSession();
//        session.removeAttribute("attr1");
//        session.invalidate();

        req.removeAttribute("attr1");

        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.println("Hello ServletD");

//        PrintWriter writer = resp.getWriter();
//        writer.println("hi ServletD");
    }
}
